﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using ZOIL.Framework.Core;
using System.Globalization;

namespace Sample.PhotoBrowser
{
    /// <summary>
    /// Interaction logic for ProgressBar.xaml
    /// </summary>
    public partial class ProgressBar : UserControl
    {


        public int CurrentTaskPercentage
        {
            get { return (int)GetValue(CurrentTaskPercentageProperty); }
            set { SetValue(CurrentTaskPercentageProperty, value); }
        }

        public static readonly DependencyProperty CurrentTaskPercentageProperty =
            DependencyProperty.Register("CurrentTaskPercentage", typeof(int), typeof(ProgressBar), new UIPropertyMetadata(0));

        public ProgressBar()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(ProgressBar_Loaded);
        }

        void ProgressBar_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = this;
            ((Storyboard)this.FindResource("ProgressBarRotation")).Begin();
        }
    }

    #region Progress Converter

    public class ProgressConverter : ConverterMarkupExtension<ProgressConverter>, IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                int val = (int)value;
                string progress = val + "";
                return progress + " %";
            }
            return "0 %";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {

            throw new Exception("The method or operation is not implemented.");

        }
    }

    #endregion
}
